package com.design.strategy.pay;


import com.design.strategy.MsgResult;

public abstract class CommonPay {


    public abstract String getName();

    public MsgResult pay(String uid, double amount) {

        // 余额不足+
        if (queryBalance(uid) < amount) {
            return new MsgResult(500, "支付失败", "余额不足");
        }
        return new MsgResult(200, "支付成功", "支付的金额" + amount);
    }

    /**
     * 钩子方法
     * @param uid
     * @return
     */
    protected abstract double queryBalance(String uid);
}
